#  Copyright (c) 2020 - ~, WANGXI
#  
#  SIMPLE TCP TCPTEST AWK FILE
#  Used in NS-2 simulator
#  Clone from https://gitee.com/WangXi_Chn/ns2_modulelib
#  Note in https://www.yuque.com/wangxi_chn/kozrfl
#  
#  Change Logs:
#  Date           Author       Notes			Mail
#  2020-11-24     WangXi   	   first version	WangXi_Chn@foxmail.com

BEGIN {
    packet_send = 0;
    packet_rcvd = 0;
    sum = 0;
}

{
    action = $1;
    time = $2;
    from = $3;
    to = $4;
    type = $5;
    pktsize = $6;
    flow_id = $8;
    src = $9;
    dst = $10;
    seq_no = $11;
    packet_id = $12;

    if(action == "+" && from == "0")
        packet_send++;
    if(action == "r" && to == "2"){
        packet_rcvd++;
        sum += pktsize;
    }
}

END {
    printf("packet_send %d,packet_rcvd %d\n",packet_send,packet_rcvd);
    printf("Good put is %ld\n",sum/8);
}

#/************************ (C) COPYRIGHT 2020 WANGXI **************END OF FILE****/
